import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { StatusEntity } from './status.entity';
import { ImagesEntity } from './images.entity';

//用户
@Entity('user')
export class UserEntity {
  @PrimaryGeneratedColumn()
  id: number;
  @Column({ comment: '用户名称' })
  name: string;
  @Column({ unique: true, comment: '邮箱' })
  email: string;
  @Column({ comment: '密码' })
  password: string;
  @Column({ comment: '密钥' })
  salt: string;
  @CreateDateColumn({
    type: 'timestamp',
    insert: false, // 不在插入时设置，由数据库自动处理
    comment: '用户创建日期',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createdAt?: Date;
  @ManyToOne(() => StatusEntity, status => status.id)
  status: number;
  @OneToMany(() => ImagesEntity, images => images.user)
  images: ImagesEntity[];
}
